#include "emoji.h"
#include "ui_emoji.h"
#include"ChatWidget.h"

emoji::emoji(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::emoji)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);//无边框但在任务栏上显示标题

}

emoji::~emoji()
{
    delete ui;
}

void emoji::on_pushButton_clicked()
{
    this->close();

}


void emoji::mousePressEvent(QMouseEvent *event)
{
    //event->globalPos()获取鼠标以电脑屏幕左上角为原点的向量
    if(event->button()==Qt::LeftButton)
    {
        this->m_moveing2=true;
        m_lastPos=event->globalPos()-pos();//使用向量的减法获得鼠标相对于窗口的位置

    }
    return  QWidget::mousePressEvent(event);

}

void emoji::mouseMoveEvent(QMouseEvent *event)
{
    //在mouseMoveEvent 里event->button()返回的引进事件的button永远是Qt::NoButton!!
    if(m_moveing2 && (event->buttons()&&Qt::LeftButton))//左键被按下
    {
        move(event->globalPos()-m_lastPos);
       //m_lastPos=event->globalPos()-pos();//使用向量的减法获得鼠标相对于窗口的位置
    }
   return QWidget::mouseMoveEvent(event);
}

void emoji::mouseReleaseEvent(QMouseEvent *event)
{
   Q_UNUSED(event);
   m_moveing2=false;
}

